package jxau.jwgl.api;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Getter;

import java.io.Serializable;
import java.util.List;

/**
 * 教务系统的返回数据格式(json)
 *
 * @author LongShu 2017/04/04
 */
@Getter
public class MessageData<T> implements Serializable {
    private static final long serialVersionUID = 1L;

    @JsonProperty("Message")
    private String Message;
    @JsonProperty("Data")
    private List<T> Data; // 一般为数组
    @JsonProperty("ExtendData")
    private List<T> ExtendData;
    @JsonProperty("OtherData")
    private Object OtherData;

    @JsonProperty("Result")
    private boolean Result;
    private boolean success;// 是否成功
    private int totalCount;// totalCount总记录数,返回TotalCount无视

    public MessageData<T> setMessage(String message) {
        Message = message;
        return this;
    }

    public MessageData<T> setData(List<T> data) {
        Data = data;
        return this;
    }

    public MessageData<T> setExtendData(List<T> extendData) {
        ExtendData = extendData;
        return this;
    }

    public MessageData<T> setOtherData(Object otherData) {
        OtherData = otherData;
        return this;
    }

    public MessageData<T> setResult(boolean result) {
        Result = result;
        return this;
    }

    public MessageData<T> setSuccess(boolean success) {
        this.success = success;
        return this;
    }

    public MessageData<T> setTotalCount(int totalCount) {
        this.totalCount = totalCount;
        return this;
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("MessageData{\n");
        sb.append("Message='").append(Message).append('\'').append('\n');
        sb.append(", Data=").append(Data).append('\n');
        sb.append(", ExtendData=").append(ExtendData).append('\n');
        sb.append(", OtherData=").append(OtherData).append('\n');
        sb.append(", Result=").append(Result).append('\n');
        sb.append(", success=").append(success).append('\n');
        sb.append(", totalCount=").append(totalCount).append('\n');
        sb.append('}');
        return sb.toString();
    }

}
